package com.example.demo.Controller;
import com.alibaba.fastjson.JSONObject;
import com.example.demo.Dao.StuScoreDao;
import com.example.demo.Dao.StudentDao;
import com.example.demo.Model.Course;
import com.example.demo.Model.StuScore;
import com.example.demo.Model.score;
import com.example.demo.Service.StudentService.ScoreService;
import com.example.demo.Service.TeacherService.CourseService;
import com.example.demo.Service.TeacherService.StuScoreService;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class StudentController {
    @Resource
    private ScoreService scoreservice;
    @Resource
    private CourseService courseservice;
    @Resource
    private StuScoreService stuscoreservice;
    @Resource
    private StuScoreDao stusocoredao;

    //学生选课
    @RequestMapping("/selectCourse1/{coID}")
    public String selectCourse1(@PathVariable("coID") String coID,HttpSession session){
        System.out.println("学生选课");
        System.out.println(coID);
        String stuID=session.getAttribute("stuID").toString();
        System.out.println(stuID);
        score score1=new score();
        score1.setStuID(stuID);
        score1.setCoID(coID);
        score1.setStuscore("暂无成绩");
        System.out.println(score1);
        scoreservice.save(score1);
        JSONObject result=new JSONObject();
        result.put("status","success");
        return result.toJSONString();
    }



}
